package com.example.eos.mapper;

import com.example.eos.bean.Collec;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CollecMapper {

    //查询用户的收藏列表
    @Select("select collecid, userid, publishid, creattime from collec where userid = #{userid,jdbcType=VARCHAR} order by creattime DESC")
    List<Collec> findByUserid(String userid);

    //查询收藏
    @Select("select collecid, userid, publishid, creattime from collec where collecid = #{collecid,jdbcType=VARCHAR}")
    Collec findByCollecid(String collecid);

    //添加收藏
    @Insert("insert into collec (collecid, userid, publishid, creattime) values (#{collecid,jdbcType=VARCHAR}, #{userid,jdbcType=VARCHAR}, #{publishid,jdbcType=VARCHAR}, #{creattime})")
    void addCollec(Collec collec);

    //删除收藏
    @Delete("delete from collec where collecid = #{collecid,jdbcType=VARCHAR}")
    void deleteCollec(String collecid);

}
